﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Ultility;

namespace Entity
{
    public partial class Entity_Account : Component
    {
        DBAccess _access = new DBAccess();
        public Entity_Account()
        {
            
            InitializeComponent();
        }

        public Entity_Account(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        #region -----Entity InfoAcc trã về thông tin Tài Khoản-----
        public DataSet _CheckType_Account(string id, string pass)
        {
            SqlParameter[] para = {new SqlParameter("@id",SqlDbType.NVarChar),
                                  new SqlParameter("@pass",SqlDbType.NVarChar)};
            para[0].Value = id;
            para[1].Value = pass;
            return _access._ExcuteQuery("sp_CheckQuyen_QuyenHan", para);
        }
        #endregion

        #region -----Entity Update Acc trã về kiểu bool-----
        public bool _UpdateAccount(string ID, string passnew)
        {

            SqlParameter[] para = {
                                      new SqlParameter("@id",SqlDbType.Char),
                                      new SqlParameter("@pass",SqlDbType.Char)
                                  };
            para[0].Value = ID;
            para[1].Value = passnew;

            return _access._ExcuteNonQuery("sp_UpdatePass", para);
        }
        #endregion

        public bool _CheckLogin(string ID, string pass)
        {
            SqlParameter[] para = { new SqlParameter("@ID", SqlDbType.Char),
                                    new SqlParameter("@Pass", SqlDbType.Char)};
            para[0].Value = ID;
            para[1].Value = pass;
            return _access._ExcuteNonQuerySelect("sp_check_login", para);
        }

        //public DataSet _checkQuyen(string id, string pass)
        //{
        //    string query = "select QuyenHan from QuyenHan, Account where Quyenhan.maQuyenHan =Account.maQuyenHan and ID ='" + id + "' and pass='" + pass + "'";
        //    return _access._ExcuteQuery(query);
        //}

        public DataSet _Check_Info_Acc(string id, string pass)
        {
            SqlParameter[] para ={new SqlParameter("@id",SqlDbType.Char),
                                     new SqlParameter("@pass",SqlDbType.Char)};
            para[0].Value = id;
            para[1].Value = pass;
            return _access._ExcuteQuery("sp_Check_InfoEmployee", para);
        }
    }
}
